package com.shipwe.language;

import android.app.Activity;
import android.app.Application;
import android.os.Bundle;

/**
 * ShipweLoans
 * @Author wwdeng
 * @CreateTime: 2024/11/8 10:55
 * @Annotation：Activity 语种注入
 */
public class ActivityLanguages implements Application.ActivityLifecycleCallbacks {

    static void inject(Application application) {
        application.registerActivityLifecycleCallbacks(new ActivityLanguages());
    }

    @Override
    public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
        ShipweLanguages.updateAppLanguage(activity);
        ShipweLanguages.updateAppLanguage(activity.getApplication());
    }

    @Override
    public void onActivityStarted(Activity activity) {}

    @Override
    public void onActivityResumed(Activity activity) {
        ShipweLanguages.updateAppLanguage(activity);
        ShipweLanguages.updateAppLanguage(activity.getApplication());
    }

    @Override
    public void onActivityPaused(Activity activity) {}

    @Override
    public void onActivityStopped(Activity activity) {}

    @Override
    public void onActivityDestroyed(Activity activity) {}

    @Override
    public void onActivitySaveInstanceState(Activity activity, Bundle outState) {}
}
